function Mom_Table = Mom_Annual(DATA , type , DATA_CellNames , MomVar_Names , Mom_RowNames , Mom_ColName)

% Given variables, calculate their annualized moments
% INPUT:
% --DATA: cell that contains simulated data
% --type: use median (1) or mean (2) to average across simulations
% --DATA_CellNames: variable names matched to cells
% --MomVar_Names: names of interested quantities
% --Mom_RowNames: names of interested quantities to display in the Table
% --Mom_ColName: name of the column to display in the Table

%% 1. Calculate Annualized Moments
%-------------------------------------
% Endowment Process
%-------------------------------------
% Consumption growth
% cg_mean = mean(cg) * 400;
% cg_std = std(cg) * 200;
cg_yoy = DATA{strcmp(DATA_CellNames , 'cg_yoy' )};
cg_yoy_mean = mean(cg_yoy * 4) * 100;
cg_yoy_std = std(cg_yoy * 4) * 100;

% Dividend growth
% dg_mean = mean(dg) * 400;
% dg_std = std(dg) * 200;
dg_yoy = DATA{strcmp(DATA_CellNames , 'dg_yoy' )};
dg_yoy_mean = mean(dg_yoy * 4) * 100;
dg_yoy_std = std(dg_yoy * 4) * 100;

%-------------------------------------
% Price Quantity
%-------------------------------------
% risk-free rate
rf = DATA{strcmp(DATA_CellNames , 'rf' )};
rf_mean = mean(rf) * 400;
rf_std = std(rf) * 400; % See Beeler and Campbell(2012)

% Excess return(simple)
EXRET = DATA{strcmp(DATA_CellNames , 'EXRET' )};
EXRET_mean = mean(EXRET) * 400;
EXRET_std = std(EXRET) * 200;
EXRET_sr = EXRET_mean./EXRET_std;
 
% P/D ratio
pd_ttm = DATA{strcmp(DATA_CellNames , 'pd_ttm' )};
pd_mean = mean(pd_ttm);
pd_std = std(pd_ttm);
pd_rho = nan(1 , size(pd_ttm , 2));
for l = 1 : size(pd_ttm , 2)
    [pd_rho_temp , ~, ~] = autocorr(pd_ttm(: , l));
    pd_rho(l) = pd_rho_temp(2);
end

%-------------------------------------
% State variable proxies
%-------------------------------------
% tmu
tmu = DATA{strcmp(DATA_CellNames , 'tmu' )};
tmu_std = std(tmu) * 400;
tmu_rho = nan(1 , size(tmu , 2));
for l =1 : size(tmu , 2)
    if sum(isnan(tmu(: , l))) == 0
    [tmu_rho_temp, ~, ~] = autocorr(tmu(: , l));
    tmu_rho(l) = tmu_rho_temp(2);
    end
end

% tmud
tmud = DATA{strcmp(DATA_CellNames , 'tmud' )};
tmud_std = std(tmud) * 400;
tmud_rho = nan(1 , size(tmud , 2));
for l =1 : size(tmud , 2)
    if sum(isnan(tmud(: , l))) == 0
    [tmud_rho_temp, ~, ~] = autocorr(tmud(: , l));
    tmud_rho(l) = tmud_rho_temp(2);
    end
end

% tmur
tmur = DATA{strcmp(DATA_CellNames , 'tmur' )};
tmur_std = std(tmur) * 400;
tmur_rho = nan(1 , size(tmur , 2));
for l =1 : size(tmur , 2)
    if sum(isnan(tmur(: , l))) == 0
    [rh_rho_temp, ~, ~] = autocorr(tmur(: , l));
    tmur_rho(l) = rh_rho_temp(2);
    end
end

% Correlation among proxies of state variable
tmu_tmur_corr = nan(1 , size(tmu , 2));
tmu_tmud_corr = nan(1 , size(tmu , 2));
tmud_tmur_corr = nan(1 , size(tmu , 2));
for l = 1 : size(tmu , 2)
    if sum(isnan(tmu(:,l))) == 0 && sum(isnan(tmud(:,l))) == 0 && sum(isnan(tmur(:,l))) == 0
    tmu_tmur_corr_temp = corrcoef(tmu(:,l) , tmur(:,l));
    tmu_tmur_corr(l) = tmu_tmur_corr_temp(1,2);
    
    tmu_tmud_corr_temp = corrcoef(tmu(:,l) , tmud(:,l));
    tmu_tmud_corr(l) = tmu_tmud_corr_temp(1,2);
    
    tmud_tmur_corr_temp = corrcoef(tmud(:,l) , tmur(:,l));
    tmud_tmur_corr(l) = tmud_tmur_corr_temp(1,2);
    end
end

%% 2. Collect Required Moments 
Result = [];
for i = 1 : length(MomVar_Names)
    Result = [Result; eval(MomVar_Names{i})];
end
 
%% 3. Output
%-------------------------------------
if type == 1
    Mom = median(Result , 2);
elseif type == 2
    Mom = mean(Result , 2);
end
                
Mom_Table = array2table(Mom , 'RowNames' , Mom_RowNames);
Mom_Table.Properties.VariableNames{1} = Mom_ColName;

end